<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
 <base href="<%=request.getContextPath()%>/">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Insert title here</title>
<link rel="stylesheet" type="text/css" href="Styles/bootstrap.min.css" />
<script type="text/javascript" src="Scripts/jquery-1.7.2.js"></script>
</head>
<body>
<a href="ppe/preExcel">从Excel文件读取信息</a>
<div class="container-fluid">
	<div class="row-fluid">
		<div class="span12">
			<form action="ppe/add" method="post" >
				<fieldset>
				     <label>部门</label>
					 <select name="depId">
					 		<option value="">请选择</option>
					 	<c:forEach items="${list }" var="dep">
							<option value="${dep.id }">${dep.name }</option>
						</c:forEach>
					 </select>
					  <label>物品名称</label><input type="text" name="name" /> <span class="help-block"></span> 
					  <label>型号</label><input type="text" name="model"/> <span class="help-block"></span> 
					  <label>数量</label><input type="text" name="number" id=txtAmount value=0 onkeyup="checkInt(this);" onpaste="checkInt(this);" oncut="checkInt(this);" ondrop="checkInt(this);" onchange="checkInt(this);"/> <span class="help-block"></span> 
					  <label>单价</label><input name="price" id=txtPrice value=0 onkeyup="checkP(this);" onpaste="checkP(this);" oncut="checkP(this);" ondrop="checkP(this);" onchange="checkP(this);" style="border-right-width:0px;margin-right:0px;"> 
										<input style="border-left-width:0px;margin-left:-4px;width:18px" value="￥" readonly>  <span class="help-block"></span> 
					  <label>总价</label><input name="sumPrice" id=txtTotal value=0 style="border-right-width:0px;margin-right:0px;" readonly> 
										<input style="border-left-width:0px;margin-left:-4px;width:18px" value="￥" readonly><span class="help-block"></span>
					  <label>购买时间</label>
					  		<input type="date" name="buyTime" onblur="FormatDate(this.value);"/>
					  <label>保险期</label><input type="text" name="baoxiu"/> <span class="help-block"></span>
					  <label>使用情况</label><input type="text" name="syqk"/> <span class="help-block"></span>
					  <label>使用详情</label><input type="text" name="syqkDetail"/> <span class="help-block"></span>
					  <label>存放地址</label><input type="text" name="address"/> <span class="help-block"></span>
					  <label>责任人</label><input type="text" name="creator"/> <span class="help-block"></span>
					  <button type="submit" class="btn">提交</button>
				</fieldset>
			</form>
		</div>
	</div>
</div>
	
</body>
</html>
<script> 
function checkInt(o){ 
theV=isNaN(parseInt(o.value))?0:parseInt(o.value); 
if(theV!=o.value){o.value=theV;} 
txtTotal.value=txtAmount.value*txtPrice.value; 
} 
function checkP(o){ 
theV=isNaN(parseFloat(o.value))?0:parseFloat(o.value); 
theV=parseInt(theV*100)/100; 
if(theV!=o.value){ 
theV=(theV*100).toString(); 
theV=theV.substring(0,theV.length-2)+"."+theV.substring(theV.length-2,theV.length) 
o.value=theV; 
} 
txtTotal.value=txtAmount.value*txtPrice.value; 
} 
//转换时间类型为 yyyy-mm-dd
function FormatDate (strTime) {
    var date = new Date(strTime);
     var formatedMonth = ("0" + (date.getMonth() + 1)).slice(-2);
     var formatedDate = ("0" + (date.getDate())).slice(-2);
    return date.getFullYear()+"-"+formatedMonth+"-"+formatedDate;
}
</script> 